<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {font-size: 12px}
.STYLE3 {font-size: 12px; font-weight: bold; }
.STYLE4 {
	color: #03515d;
	font-size: 12px;
}
-->
</style>
<script charset="utf-8" src="common/jquery/jquery.js"></script>
<link rel="stylesheet" href="common/kindeditor-4.1.3/themes/default/default.css" />
<link rel="stylesheet" href="common/kindeditor-4.1.3/plugins/code/prettify.css" />
<script charset="utf-8" src="common/kindeditor-4.1.3/kindeditor.js"></script>
<script charset="utf-8" src="common/kindeditor-4.1.3/lang/zh_CN.js"></script>
<script charset="utf-8" src="common/kindeditor-4.1.3/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
				editor = K.create('textarea[name="classType.detail"]', {
				    cssPath : 'common/kindeditor-4.1.3/plugins/code/prettify.css',
				    width:'100%',
				    uploadJson : 'uploadDemoAction!uploadImage.action',
				    fileManagerJson : 'common/kindeditor-4.1.3/jsp/file_manager_json.jsp',
					allowFileManager : true,
					afterCreate : function() { 
                      this.sync(); 
                     }, 
                    afterBlur:function(){ 
                      this.sync(); 
                    }    
				});
				editor = K.create('textarea[name="product.explainInfo"]', {
				    cssPath : 'common/kindeditor-4.1.3/plugins/code/prettify.css',
				    width:'100%',
				    uploadJson : 'uploadDemoAction!uploadImage.action',
				    fileManagerJson : 'common/kindeditor-4.1.3/jsp/file_manager_json.jsp',
					allowFileManager : true,
					afterCreate : function() { 
                      this.sync(); 
                     }, 
                    afterBlur:function(){ 
                      this.sync(); 
                    }    
				});
			var editor = K.editor({
			    cssPath : 'common/kindeditor-4.1.3/plugins/code/prettify.css',
				uploadJson : 'uploadDemoAction!uploadImage.action',
				fileManagerJson : 'common/kindeditor-4.1.3/jsp/file_manager_json.jsp',
					allowFileManager : true
				});
				K('#upload_picture_button').click(function() {
					editor.loadPlugin('image', function() {
						editor.plugin.imageDialog({
							showRemote : false,
							imageUrl : K('#classType_imageAdd').val(),
							clickFn : function(url, title, width, height, border, align) {
								K('#classType_imageAdd').val(url);
								var localImagId = document.getElementById("headImageView");
                                    localImagId.src=url;
								editor.hideDialog();
							}
						});
					});
				});
				K('#add_picture_button').click(function() {
					editor.loadPlugin('image', function() {
						editor.plugin.imageDialog({
							imageUrl : K('#classType_imageAdd').val(),
							clickFn : function(url, title, width, height, border, align) {
								K('#classType_imageAdd').val(url);
								var localImagId = document.getElementById("headImageView");
                                    localImagId.src=url;
								editor.hideDialog();
							}
						});
					});
				});
				K('#upload_book_button').click(function() {
					editor.loadPlugin('image', function() {
						editor.plugin.imageDialog({
							showRemote : false,
							imageUrl : document.getElementById("book_bookAdd").value,
							clickFn : function(url, title, width, height, border, align) {
								//K('#addressbookUrl').val(url);
								var addressbookUrl=document.getElementById("book_bookAdd");
								addressbookUrl.value=url;
								editor.hideDialog();
							}
						});
					});
				});
				K('#add_book_button').click(function() {
					editor.loadPlugin('image', function() {
						editor.plugin.imageDialog({
							imageUrl : document.getElementById("book_bookAdd").value,
							clickFn : function(url, title, width, height, border, align) {
								//K('#addressbookUrl').val(url);
								var addressbookUrl=document.getElementById("book_bookAdd");
								addressbookUrl.value=url;
								editor.hideDialog();
							}
						});
					});
				});
				
		});
	</script>
<script>
     function validateForm(){
    	//解析内容图片
    	 var content=$('#classType_detail').val();//得到html代码       
         var imgcount = 0;       
         var matchArray1,matchArray2=[],matchArray3=[],tmp_matchArray1=[];errorCounter=0;
         var hostname=location.hostname.replace(/\./g,'\\.');
         //var reg=/<img[^>]+src=['"](http:\/\/[^'"]*)['"]/ig;
         
         //匹配图片（g表示匹配所有结果i表示区分大小写）
         var imgReg = /<img.*?(?:>|\/>)/gi;
         var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
         var arr = content.match(imgReg);
         var imagelistStringTemp="";
         for (var i = 0; i < arr.length; i++) {
        	    var src = arr[i].match(srcReg);
        	    //获取图片地址
        	    if(src[1]){
        	       //alert('已匹配的图片地址'+(i+1)+'：'+src[1]);
        	    	imagelistStringTemp=imagelistStringTemp+","+src[1];
        	    }
        	    
        	}
         //alert(imagelistStringTemp);
         $("#imagelistString").val(imagelistStringTemp);
         //解析内容图片end
     var localVar = document.getElementById("classType_typeTitle");
      if(localVar.value.length<2)
       {
           alert("名称格式不正确");
           localVar.focus();
           return false;
       }
     var localVar1 = document.getElementById("classType_typeOrder");
      if(localVar1.value.length<1)
       {
            alert("排序格式不正确");
           localVar1.focus();
           return false;
       }
     
      
       return true;  
       
     }
    </script>


</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td>&nbsp;</td> </tr>
  <tr>
    <td height="30" background="tab/images/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="30"><img src="tab/images/tab_03.gif" width="12" height="30" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="80%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><div align="center"><img src="tab/images/tb.gif" width="16" height="16" /></div></td>
                <td width="95%" class="STYLE1"><span class="STYLE3">你当前的位置</span>：[添加信息]</td>
              </tr>
            </table></td>
            <td width="54%">
			    &nbsp;
			</td>
          </tr>
        </table></td>
        <td width="16"><img src="tab/images/tab_07.gif" width="16" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  
  <tr>
      <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="8" background=" tab/images/tab_12.gif">&nbsp;</td>
        <td>
          <s:form  action="gKLBookTypeAction!saveClassType.action" method="post" theme="simple" onsubmit="return validateForm();">
          <s:hidden name="classType.id"/>
          <s:hidden name="classTypeId"/>  
          <s:hidden name="classType.imagelistString" id="imagelistString"/>        
		<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6" onmouseover="changeto()"  onmouseout="changeback()">
           <tr>          
            <td height="30" bgcolor="#FFFFFF"><div align="right"><span class="STYLE1">分类图标</span></div></td>
            <td height="30" bgcolor="#FFFFFF"><div align="left"><span class="STYLE1">
               <s:hidden name="classType.imageAdd" id="classType_imageAdd"/>
               <img id="headImageView"   src="${classType.imageAdd}" alt="" width="100px" height="120px"/>&nbsp;
               <input type="button" name="upload_picture_button" id="upload_picture_button" value="上传图片"/>&nbsp;
               <input type="button" name="add_picture_button" id="add_picture_button" value="添加图片"/> </span></div>
           </td>
           <tr>          
            <td height="30" bgcolor="#FFFFFF"><div align="right"><span class="STYLE1">标题</span></div></td>
            <td height="30" bgcolor="#FFFFFF"><div align="left"><span class="STYLE1"><s:textfield name="classType.typeTitle" id="classType_typeTitle" size="60"/>*(2字符上)</span> <s:fielderror cssStyle="color:red;font-size: 12px"><s:param>realNameError</s:param></s:fielderror></div></td>
           </tr>
           <s:if test="columnTag!=6">
           <tr>          
            <td height="30" bgcolor="#FFFFFF"><div align="right"><span class="STYLE1">副标题</span></div></td>
            <td height="30" bgcolor="#FFFFFF"><div align="left"><span class="STYLE1"><s:textfield name="classType.subTitle" id="classType_typeTitle" size="60"/>*(2字符上)</span> <s:fielderror cssStyle="color:red;font-size: 12px"><s:param>realNameError</s:param></s:fielderror></div></td>
           </tr>
           <tr>          
            <td height="30" bgcolor="#FFFFFF"><div align="right"><span class="STYLE1">显示时间</span></div></td>
            <td height="30" bgcolor="#FFFFFF"><div align="left"><span class="STYLE1"><s:textfield name="classType.viewDate" id="classType_viewDate" size="60"/>*(2字符上,例如：2012-12-12)  </span> <s:fielderror cssStyle="color:red;font-size: 12px"><s:param>realNameError</s:param></s:fielderror></div></td>
           </tr>
		    <tr>          
            <td height="30" bgcolor="#FFFFFF"><div align="right"><span class="STYLE1">排序</span></div></td>
            <td height="30" bgcolor="#FFFFFF"><div align="left"><span class="STYLE1"><s:textfield name="classType.typeOrder" id="classType_typeOrder" size="60"/>*(数字)</span></div></td>
           </tr>
           <tr>          
            <td height="30" bgcolor="#FFFFFF"><div align="right"><span class="STYLE1">内容描述</span></div></td>
            <td height="30" bgcolor="#FFFFFF"><div align="left"><s:textarea name="classType.detail" id="classType_detail" cssStyle="width:400px;height:300px;visibility:hidden;" /></div> </td>
           </tr>
           </s:if>
		   <tr>          
            <td height="30" bgcolor="#FFFFFF" colspan="2"><div align="center"><input type="submit"  value="保存"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button"  value="返回" onclick="history.back();" /></div></td>
           </tr>
        </table>
        </s:form>
        </td>
        <td width="8" background="tab/images/tab_15.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
 <!-- <tr>&nbsp;</tr>-->
  <tr>
    <td height="35" background="tab/images/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="35"><img src="tab/images/tab_18.gif" width="12" height="35" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td class="STYLE4">&nbsp;&nbsp</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
        <td width="16"><img src="tab/images/tab_20.gif" width="16" height="35" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
